package com.woniuxy.service.impl;

import com.woniuxy.dao.RegisterDao;
import com.woniuxy.entity.Register;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.Warehouse;
import com.woniuxy.service.RegisterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class RegisterServiceImpl implements RegisterService {
    @Resource
    RegisterDao registerDao;
    @Override
    public ResponseEntity addOne(Register register) {
        int index = registerDao.addOne(register);
        if (index > 0) {
            return ResponseEntity.SUCCESS;
        }
        return ResponseEntity.Fail;
    }

    @Override
    public ResponseEntity findByNo(String no) {
        Register register = registerDao.findByNo(no);
        if (register!=null){
            return new ResponseEntity(200,"成功",register);
        }
        return ResponseEntity.Fail;
    }

    @Override
    public ResponseEntity findByAccount(String account) {
        Register register = registerDao.findByAccount(account);
        if (register!=null){
            return new ResponseEntity(200,"成功",register);
        }
        return ResponseEntity.Fail;
    }

    @Override
    public ResponseEntity findByUsername(String username) {
        Register register = registerDao.findByUsername(username);
        if (register!=null){
            return new ResponseEntity(200,"成功",register);
        }
        return ResponseEntity.Fail;
    }

    @Override
    public ResponseEntity findAll() {
        return new ResponseEntity<>(200, "成功", registerDao.findAll());
    }

}
